<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.net.URLDecoder,java.net.URLEncoder,cn.edu.nju.ws.sview.views.Comment,cn.edu.nju.ws.sview.views.Image,cn.edu.nju.ws.sview.Config,cn.edu.nju.ws.sview.views.Group,cn.edu.nju.ws.sview.util.URIUtil,java.util.Enumeration,java.util.ArrayList,cn.edu.nju.ws.sview.util.URIUtil,cn.edu.nju.ws.sview.views.Entity,cn.edu.nju.ws.sview.views.data.EntityManagement,cn.edu.nju.ws.sview.views.data.EntityManagement.URIMember,cn.edu.nju.ws.sview.cache.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SView识认</title>
<link rel="icon" href="/sview/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/sview/css/layout.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/smoothness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/views/identity.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/easyui.css" />
<script type="text/javascript" src="/sview/script/jquery.js"></script>
<script type="text/javascript" src="/sview/script/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/sview/script/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="/sview/script/global.js"></script>
<script type="text/javascript" src="/sview/script/views/identity_collection.js"></script>
</head>
<body>
	<%
		String lang = request.getParameter("lang");
		if (lang != null && lang.equals("en")) {
			request.getRequestDispatcher("construct_collection.jsp")
					.forward(request, response);
			return;
		} else if (lang == null) {
			lang = "zh";
		}

		String genre = request.getParameter("genre");
		String eidStr = request.getParameter("eid");
		String curmemcidStr = request.getParameter("curmemcid");
		int eid = 0;
		int etype = 0;
		int curmemcid = 0;
		if (genre == null || curmemcidStr == null) {
			String location = "../views/index.jsp";
			if (lang.equals("zh"))
				location = location + "?lang=" + lang;
			response.sendRedirect(location);
			return;
		} else {
			eid = Integer.parseInt(eidStr);
			curmemcid = Integer.valueOf(curmemcidStr);
		}

		etype = Entity.COLLECTION;

		String testName = Entity.getNameByEntityID(eid, "zh");
		if (testName == null) {
			String location = "eerror.jsp";
			if (lang.equals("zh"))
				location = location + "?lang=" + lang;
			response.sendRedirect(location);
			return;
		}

		String gname = null;
		if (session.getAttribute("groupName") != null) {
			gname = (String) session.getAttribute("groupName");
		} else {
			String location = "../views/index.jsp";
			if (lang.equals("zh"))
				location = location + "?lang=" + lang;
			response.sendRedirect(location);
			return;
		}

		int gid = Group.getGroupIdByName(gname);

		String ename = request.getParameter("n");
		if (ename != null) {
			ename = URLDecoder.decode(ename, "utf-8");
		}
	%>
<jsp:include page="/vheader_zh.jsp" flush="true">
   <jsp:param name="f" value="e"/>
</jsp:include>
<div class="container">
   <div class="top">
      <div class="mspacing"></div>
      <%
      	if (!Entity.isTmpCollection(etype, eid)) {
      %>
      <div class="operation">编辑自定义集合</div>
      <%
      	} else {
      %>
       <div class="operation">创建自定义集合</div>
      <%
      	}
      %>
      <div class="edit-save"> 
         <input type="button" value="保存" class="sbutton btn btn-primary fb">
         <input type="button" value="取消" class="cbutton btn fb">
       </div>
   </div>
   <div class="mspacingLittle"></div>
      <div class="main">
	     <div class="entityName section">
	     	<div class="tab-header">
	           <div class="tab" >
			       <span class="title">基本信息</span>
			       <span class="tab-status"></span>
			    </div>
	        </div>	     
			<div class="content">
			    <div class='namebox'>
                   <span class="label">名称:</span>
                   <span>
                      <%
                      	if (ename == null) {
                      		ename = Entity.getNameByEntityID(eid, "zh");
                      	}
                      %>
                            <input class="ftext inename" value="<%=ename%>" type="text">
                   </span>                 
                 </div>
               
                 <div class='descbox'>
                    <span class="label">描述:</span>
                    <span>
                    <%
                    	String comment = null;
                    	Comment commObj = Comment.getCommentByMemberLangGroup(etype, eid,
                    			lang, gname);
                    	if (commObj != null) {
                    		comment = commObj.getText();
                    	}
                    %>
                    <%
                    	if (comment != null && !comment.trim().equals("")) {
                    %>
                    	<textarea class="ftext commentarea "><%=comment%></textarea>
                    <%
                    	} else {
                    %>
                     	<textarea class="ftext commentarea "></textarea>
                    <%
                    	}
                    %>
                    </span>
                 </div>
			</div>
		 </div>  
	     <div class="identity section">
		    <div class="tab-header">
	           <div class="tab" >
			       <span class="title">成员</span>
			       <span class="tab-status"></span>
			    </div>
	        </div>
			<div class="content">
				<div class="leftPanel">
					<div class="entity-list"></div>
					<div class="advancedBox">
					    <a  href="javascript:void(0)" class="advancedSwitch">手动添加URI</a>
					    <div class="content">
					    	<div class='header'>输入一个 uri 来作为成员:</div>
					    	<div><input id="uriAdded" type="text" size="75" value="http://"  class ="ftext"></div>
					    	<div class="opBox">
					    	<input type="button" value="确定" class="addbtn" id="addbtn" />
					    	<input type="button" value="重置" class="rstbtn" id="rstbtn" />
					    	</div>
                            <div class="input-status">
					    	  <div class="wait sts">
					    		  <div class="hint"><span>检查中...</span></div>
					    	  </div>
					    	  <div class="valid sts"></div>
					    	  <div class="invalid sts"><img src="/sview/icons/warning.png"></img>抱歉, SView 没有找到关于这个 uri 的 RDF 描述.</div>
					       </div>						    	
					    </div>
					</div>				
				</div>
				<div class='rightPanel'>
				   <div class="recommendSection">
			        <ul>
		               <li><a href="#tabs-search">Falcons 搜索</a></li>
		               <li><a href="#tabs-removed">移除的</a></li>
	                </ul>
                    <div id="tabs-search">
                        <div class="searchBox">
                            <input id="query" type="text" size="75" value=""  class ="ftext" name="query">
         	                <input type="button" value="搜索" class="sbtn" id="searchq">
                        </div>
	                  	<div class="content">
	                  	   <ul class="entityList"></ul>
	                  	</div>
	                 </div>	   	                 
	                <div id="tabs-removed">
	                  	<div class="content">
	                  	   <ul class="entityList"></ul>
	                  	</div>
	                 </div>
				    </div>
				   </div>
			</div>
		 </div>	 
	   </div>
</div>
	<input type="hidden" id="gid" value="<%=gid%>" />
	<input type="hidden" id="gname" value="<%=gname%>" />
	<%
				if (ename != null) {
			%>
	<input type="hidden" id="ename" value="<%=ename%>" />
	<%
		}
	%>
	<input type="hidden" id="display-lang" value="zh" />
	<input type="hidden" id="genre" value="<%=genre%>" />
	<input type="hidden" id="curmemcid" value="<%=curmemcid%>" />
<%
	if (!Entity.isTmpCollection(etype,eid)) {
%>
<input type="hidden" id="custom_type" value="edit" />
<%
	} else {
%>
<input type="hidden" id="custom_type" value="create" />
<%
	}
%>	
	<input type="hidden" id="etype" value="<%=etype%>" />
	<input type="hidden" id="eid" value="<%=eid%>" />	
<jsp:include page="/vfooter_zh.jsp"></jsp:include>
</body>
</html>